﻿import mysql.connector;


class toke():

	def __int__(self,name_i):

		self.name_i=name_i

		self.mydb = mysql.connector.connect(
		  host="localhost",       # 数据库主机地址
		  user="root",    # 数据库用户名
		  passwd="root",   # 数据库密码
		  database="weizandata"
		)

	def getToke(self,name_i):


		mycursor = self.mydb.cursor()
		sql="SELECT toke FROM toke WHERE name_i ='"+ name_i +"';"
		mycursor.execute(sql)
		myresult = mycursor.fetchall()     # fetchall() 获取所有记录

		return myresult[0][0]

	def addData(self,ssql,name):
		print('1.', conn)
		cmd = self.mydb.cursor()
		# ssql = 'insert into test(sname,age)values(%s,%s)'
		# name = [('susu1', 11), ('susu2', 12), ('susu3', 13), ('susu4', 14), ('susu5', 15), ('susu6', 16), ('susu7', 17),('susu8', 18)]
		cmd.executemany(ssql, name)
		conn.commit()
		print('4.', cmd.rowcount, '条记录插入成功')

if __name__=='__main__':

	#print(toke().getToke('yq'));

	#print(toke().getWxUserInfo('oW2Wk1VNG0-mJUbKvMphScwmdTNU'))

	# print(toke().upLieBianToke())